<?php

class NoticiasController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
        $request = $this->getRequest();
        $noticiaID = $request->getParam("id");

        $noticiaObj = new Application_Model_Noticia();
        $noticia = $noticiaObj->getById($noticiaID);

        if($noticia[0]['galeria_id']){
            $galeriaObj = new Application_Model_Galeria();
            $galeria = $galeriaObj->getById($noticia[0]['galeria_id']);
        }else{
            $galeria = false;
        }

        if($noticia[0]['video_id']){
            $videoObj = new Application_Model_Video();
            $video = $videoObj->getById($noticia[0]['video_id']);
        }else{
            $video = false;
        }
		
		$noticias_sidebar = $noticiaObj->getLastLimit(4);

		$obj_eventos = new Application_Model_Evento();
		$eventos_sidebar = $obj_eventos->getEventosLimit(4);
		
		$obj_revistas = new Application_Model_Revista();
		$revistas_sidebar = $obj_revistas->getLastLimit(4);
		
        $this->view->noticia = $noticia[0];
        $this->view->galeria = $galeria;
        $this->view->video = $video;
		$this->view->noticias_sidebar = $noticias_sidebar;
		$this->view->eventos_sidebar = $eventos_sidebar;
		$this->view->revistas_sidebar = $revistas_sidebar;
		
		$noticias_footer = $noticiaObj->getLastLimit(2);
		$this->view->noticias_footer = $noticias_footer;
		
		$obj_videos = new Application_Model_Video();
		$video_footer = $obj_videos->getLastVideo();
		$this->view->video_footer = $video_footer[0];
		
		$obj_cartones = new Application_Model_Carton();
		$carton_footer = $obj_cartones->getLastCarton();
		$this->view->carton_footer = $carton_footer;
    }

    public function listaAction()
    {
        // action body
        $noticiaObj = new Application_Model_Noticia();
        $noticias = $noticiaObj->getLast20();
		$noticias_sidebar = $noticiaObj->getLastLimit(4);

		$obj_eventos = new Application_Model_Evento();
		$eventos_sidebar = $obj_eventos->getEventosLimit(4);
		
		$obj_revistas = new Application_Model_Revista();
		$revistas_sidebar = $obj_revistas->getLastLimit(4);
		
        $this->view->noticias = $noticias;
		$this->view->noticias_sidebar = $noticias_sidebar;
		$this->view->eventos_sidebar = $eventos_sidebar;
		$this->view->revistas_sidebar = $revistas_sidebar;
		
		$noticias_footer = $noticiaObj->getLastLimit(2);
		$this->view->noticias_footer = $noticias_footer;
		
		$obj_videos = new Application_Model_Video();
		$video_footer = $obj_videos->getLastVideo();
		$this->view->video_footer = $video_footer[0];
		
		$obj_cartones = new Application_Model_Carton();
		$carton_footer = $obj_cartones->getLastCarton();
		$this->view->carton_footer = $carton_footer;
    }


}



